﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class FilmBLO
    {
        private FilmDAO _filmDao = new FilmDAO(); 

        /// <summary>
        /// load films
        /// </summary>
        /// <returns>list of film</returns>
        /// <author>hungph</author>
        public List<Film> LoadFilms()
        {
            var listFilm = _filmDao.LoadFilms();
            return listFilm;
        }

        /// <summary>
        /// load film by Id
        /// </summary>
        /// <returns>Film</returns>
        /// <author>hungph</author>
        public Film LoadFilmsById(int id)
        {
            var film = _filmDao.LoadFilmsById(id);
            return film;
        }

        /// <summary>
        /// Create new film
        /// </summary>
        /// <returns>success: true; fail: false</returns>
        /// <author>hungph</author>
        public bool CreateFilm(Film film)
        {
            var result = _filmDao.Add(film);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// edit film
        /// </summary>
        /// <returns>success: true; fail: false</returns>
        /// <author>hungph</author>
        public bool EditFilm(Film film)
        {
            var result = _filmDao.Edit(film);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// delete film
        /// </summary>
        /// <returns>success: true; fail: false</returns>
        /// <author>hungph</author>
        public bool DeleteFilm(Film film)
        {
            var result = _filmDao.Delete(film);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}